﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Grain.Crm.ExcelExtractor;
using Grain.Crm.ExcelExtractor.InputDescription.Sheets;
using Grain.Crm.ExcelImporter.Serializer;
using System.IO;
using Grain.Crm.Common;
using Grain.Crm.ExcelProcessor;

namespace Grain.Crm.ExcelExtractor 
{
    public class SheetsManager
    {
        public static void BuildDescriptions(
            out ProfileSheetDescription profile, out SkillsSheetDescription skills, 
            out WorkingExperienceSheetDescription workingExperienceSheetDescription, 
            out ProjectExperienceSheetDescription projectExperienceSheetDescription,
            out CoursesSheetDescription coursesSheetDescription,
            out EducationSheetDescription educationSheetDescription)
        {
            profile = new ProfileSheetDescription();
            profile.Build();

            skills = new SkillsSheetDescription();
            skills.Build();

            workingExperienceSheetDescription = new WorkingExperienceSheetDescription();
            workingExperienceSheetDescription.Build();

            projectExperienceSheetDescription = new ProjectExperienceSheetDescription();
            projectExperienceSheetDescription.Build();

            coursesSheetDescription=new CoursesSheetDescription();
            coursesSheetDescription.Build();
            
            educationSheetDescription=new EducationSheetDescription();
            educationSheetDescription.Build();
        }

        public static void InvokeInitialSerialization()
        {
            var sheet1 = new ProfileSheetDescription();
            sheet1.Build();
            var serializer1 = new DataSerializer<ProfileSheetDescription>();
            serializer1.Serialize("ProfileSheetDescription.xml", sheet1);


            var sheet2 = new SkillsSheetDescription();
            sheet2.Build();
            var serializer2 = new DataSerializer<SkillsSheetDescription>();
            serializer2.Serialize("SkillsSheetDescription.xml", sheet2);
        }

        public static void DeserializeDescriptions(out ProfileSheetDescription profile, out SkillsSheetDescription skills)
        {
            var serializer1 = new DataSerializer<ProfileSheetDescription>();
            profile = serializer1.Deserialize(Helper.AssemblyDirectory + @"\ProfileSheetDescription.xml");

            var serializer2 = new DataSerializer<SkillsSheetDescription>();
            skills = serializer2.Deserialize(Helper.AssemblyDirectory + @"\SkillsSheetDescription.xml");
        }
    }
}
